package com.acme.bankapp.domain.bank;

import com.acme.bankapp.service.bank.AccountDoesntExistsException;

public class Client {
	private String name;
	private Account account;
	private Gender gender;

	public String getClientSalutation() {
		return gender.getSalutation() + getName();
	}

	public Client() {
	}

	public Client(String name, Gender gender, Account account) {
		this.account = account;
		this.gender = gender;
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public Gender getGender() {
		return gender;
	}

	public Account getAccount() throws AccountDoesntExistsException {
		if (account == null)
			throw new AccountDoesntExistsException(
					"Failure! Tried to get missing account");
		return account;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void addAccount(Account account) {
		this.account = account;
		System.out.println("New " + account.getClass().getSimpleName()
				+ " for client added");
	}
}
